package com.lcq.lcqeventbus;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.lcq.lcqlib.msgbus.org.greenrobot.eventbus.EventBus;
import com.lcq.lcqlib.msgbus.org.greenrobot.eventbus.Subscribe;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EventBus.builder()
                .addIndex(new MyEventBusIndex())
                .installDefaultEventBus();
        EventBus.getDefault().register(this);
    }

    @Subscribe
    public void handleMsg(String msg) {
        Toast.makeText(this, "msg:" + msg, Toast.LENGTH_LONG).show();
    }

    public void onClick(View v) {
        EventBus.getDefault().post("HELLO,EventBus APT");
    }
}